package be.music.tool.time;

public class Time {

	private long hours = 0;
	private long minutes = 0;
	private long seconds = 0;
	
	public Time() {
		
	}
	
	public Time(long hours, long minutes, long seconds) {
		
		setSeconds(seconds);
		setMinutes(minutes);
		setHours(hours);
		
	}
	
	public long getHours() {
		return hours;
	}
	public void setHours(long hours) {
		this.hours = hours;
	}
	public long getMinutes() {
		return minutes;
	}
	public void setMinutes(long minutes) {
		this.minutes = minutes;
	}
	public long getSeconds() {
		return seconds;
	}
	public void setSeconds(long seconds) {
		this.seconds = seconds;
	}
	
	public long getTimeInSeconds() {
		long hoursInSeconds = hours * 3600;
		long minutesInSecounds = minutes * 60;
		
		return hoursInSeconds + minutesInSecounds + seconds;
	}
	
	public boolean isBefore(Time time) {
		return getTimeInSeconds() < time.getTimeInSeconds();
	}
	
	public boolean isAfter(Time time) {
		return getTimeInSeconds() > time.getTimeInSeconds();
	}
	
	public boolean isAfterIncl(Time time) {
		return (this.equals(time) || this.isAfter(time));
	}
	
	public boolean isBeforeIncl(Time time) {
		return (this.equals(time) || this.isBefore(time));
	}
	
	public boolean isBetween(Time time1, Time time2) {
	
		return this.isAfterIncl(time1) && this.isBeforeIncl(time2);
 		
	}
	
	@Override
	public String toString() {
		return hours + ":" + minutes + ":" + seconds;
	}
	
	@Override
	public boolean equals(Object obj) {
		
		boolean result = false;
		
		if(this == obj) {
			
			result = true;
			
		}else if(obj.getClass() == this.getClass()) {
			
			Time time = (Time) obj;
			
			if(time.seconds == this.seconds && time.minutes == this.minutes && time.hours == this.hours) {
				result = true;
			}
			
		}
		
		return result;
	}
	
}
